package com.mingtu.guards.share;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.SPStaticUtils;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.util.XPopupUtils;
import com.mingtu.common.utils.SPTools;
import com.mingtu.guards.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @ClassName :
 * @Author : wkk
 * @Date : 2022-2-16 18:01:54
 * @Email : 1281573890@qq.com
 * @Eescription :
 */
public class BottomPopupShare2 extends BottomPopupView {
    @BindView(R.id.layout_wechat)
    LinearLayout layoutWechat;
    @BindView(R.id.layout_moment)
    LinearLayout layoutMoment;
    @BindView(R.id.layout_favorite)
    LinearLayout layoutFavorite;
    @BindView(R.id.but_cancle)
    Button butCancle;
    @BindView(R.id.layout_down)
    LinearLayout layoutDown;
    private OnItemClickListener mOnItemClickListener = null;

    public BottomPopupShare2(@NonNull Context context) {
        super(context);

    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.layout_share2;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        ButterKnife.bind(this);
        boolean download = SPStaticUtils.getBoolean(SPTools.download);
        if (download) {
            layoutDown.setVisibility(View.VISIBLE);
        } else {
            layoutDown.setVisibility(View.GONE);
        }
    }

    @Override
    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
    }

    @Override
    protected int getMaxHeight() {
        return (int) (XPopupUtils.getScreenHeight(getContext()) * .7f);
    }

    @OnClick({R.id.layout_wechat, R.id.layout_moment, R.id.layout_favorite, R.id.layout_down, R.id.but_cancle})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.layout_wechat:
                mOnItemClickListener.onItemClick(view, 0);
                break;
            case R.id.layout_moment:
                mOnItemClickListener.onItemClick(view, 1);
                break;
            case R.id.layout_favorite:
                mOnItemClickListener.onItemClick(view, 2);
                break;
            case R.id.layout_down:
                mOnItemClickListener.onItemClick(view, 3);
                break;
            case R.id.but_cancle:
                mOnItemClickListener.onItemClick(view, 4);
                break;
        }
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        this.mOnItemClickListener = listener;
    }

    public static interface OnItemClickListener {
        void onItemClick(View view, int position);
    }
}
